define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'brandnew/index',
        add_url: 'brandnew/add',
        edit_url: 'brandnew/edit',
        delete_url: 'brandnew/delete',
        export_url: 'brandnew/export',
        modify_url: 'brandnew/modify',
        adopt_url: 'brandnew/adopt_url',
        reject_url: 'brandnew/reject_url',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [
                        {
                            text: '添加',
                            url: init.add_url,
                            method: 'open',
                            auth: 'add',
                            class: 'layui-btn layui-btn-normal layui-btn-sm',
                            icon: 'fa fa-plus ',
                            extend: 'data-full="true"',
                        }
                    ],
                ],
                cols: [[
                    {field: 'class_name', title: '种类', search: false},
                    {field: 'vehicle_brand', title: '品牌', search: false},
                    {field: 'titlt', title: '标题'},
                    {field: 'level', title: '级别',selectList: {1:'轿车',2: 'SUV',3: 'MPV',4: '越野',5: '跑车',6: '其他'}},
                    {field: 'power_type', title: '动力种类',selectList: {1:'纯电',2: '混动',3:'燃油'}},
                    {field: 'mileage', title: '行驶里程', search: false},
                    {field: 'equipped_withdisplacement', title: '排量', search: false},
                    {field: 'vehicle_color', title: '颜色', search: false},
                    {field: 'registration_time',title: '上牌时间', search: false},
                    {field: 'status', title: '状态',selectList: {0:'待审核',1:'已上架',2: '已驳回'}, search: false},
                    {field: 'create_time',title: '添加时间', search: false},
                    {
                        width: 250,
                        title: '操作',
                        templet: function (d) {
                            if (d.status == 1) {
                                return '<a class="layui-btn layui-btn-success layui-btn-xs" data-open="authorize/index?id='+d.id+'" data-title="授权车辆">授权</a>'+
                                '<a class="layui-btn layui-btn-blue layui-btn-xs" data-full="true" data-open="brandnew/edit?id='+d.id+'" data-title="编辑信息">编辑</a>'+
                                '<a class="layui-btn layui-btn-danger layui-btn-xs" data-request="brandnew/delete?id='+d.id+'" data-title="确定删除？">删除</a>';
                            }else{
                                return "";
                            }
                        },
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        reject_url: function () {
            ea.listen();
        },
    };
    return Controller;
});